import { Table, Column, DataType, Model } from "sequelize-typescript";

// 使用更简单的方式定义User模型
@Table({
  tableName: "jmd_user",
  timestamps: true,
  underscored: true,
  comment: "用户信息表",
})
export class User extends Model {
  // 用户ID
  @Column({
    type: DataType.INTEGER,
    primaryKey: true,
    autoIncrement: true,
    comment: "用户ID",
  })
  declare id: number;

  // 用户名
  @Column({
    type: DataType.STRING(50),
    allowNull: false,
    unique: true,
    comment: "用户名",
  })
  username!: string;

  // 密码
  @Column({
    type: DataType.STRING(255),
    allowNull: false,
    comment: "密码",
  })
  password!: string;

  // 昵称
  @Column({
    type: DataType.STRING(50),
    allowNull: true,
    comment: "昵称",
  })
  nickname!: string;

  // 邮箱
  @Column({
    type: DataType.STRING(100),
    allowNull: true,
    comment: "邮箱",
  })
  email!: string;

  // 手机号
  @Column({
    type: DataType.STRING(20),
    allowNull: true,
    comment: "手机号",
  })
  phone!: string;

  // 用户状态
  @Column({
    type: DataType.TINYINT,
    allowNull: false,
    defaultValue: 1,
    comment: "用户状态: 0-禁用, 1-启用",
  })
  status!: number;
}
